<template>
	<view>
		<!--添加日记本-->
		<!--日期选择-->		
		<uni-forms ref="form" :modelValue="formData" >
		<view>
			<uni-datetime-picker :border="false"  v-model="time"/>
		</view>
<!--分类选项-->
		<view>
			<button @click="ww">选择项目
				<u-tag text="未选择项目" shape="circle" style="height: 50px;width: 100px;"></u-tag>
				<view v-for="(item,index) in bbb" :key="index" class="root" style="margin-left: 10px">
					<view>{{item}}</view>
				</view>
			</button>
		</view>
		
		<!-- <uni-section title="只选择图片" type="line">
					<view class="example-body">
						<uni-file-picker limit="1" title="最多选择1张图片"></uni-file-picker>
					</view>
				</uni-section> -->
<!-- 		<uni-section type="line" @click="uer">
			<view>
				<view>
					术前照片
				</view>
				<button style="height: 90px; width:90px; float: left;">
					<image src="../../static/tabBar/fbhei.png" style="width:50px; height:50px; padding-top: 20px;">
					</image>
				</button>
			</view>
		</uni-section> -->
		<button @click="submit">Submit</button>
				</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],//分类的数组然后分隔开
				bbb: [],//存在bbb里面
				formData:{},
				form:[],
				time:'',
				aaa:[] //分隔
			}
		},
		onLoad(res) {
			this.list = res.item
			this.aaa = this.list.replace('[','').replace(']','').replaceAll('"','')
			this.aaa.split(',').forEach((item) => {
				this.bbb.push(item)                                               
			})
			console.log(this.bbb)
		},
		 //添加的方法
		methods: {
				submit() {
				uni.request({
					url:'http://localhost:8090/contents/diary/add',
					method: 'post',
					dataType:'json',
					data:{
						diaryItemLabelName:this.aaa,
						time:this.time,
					} }).then(res => {
						console.log(this.aaa+this.time)
						uni.navigateTo({
							url: '/pages/publish/diary',
						});
					})
				},
			
			// aaa(){
			// 	var aa = this.list.s(',')
			// 	console.log(aa)
			// },
			ww() {
				//跳转到项目选项
				uni.navigateTo({
					url: '/pages/publish/category',

				});
			},
			//跳转到相册列表
			uer() {
				uni.navigateTo({
					url: '/pages/publish/album'
				})
			}
		},
		mounted() {
			
		}


	}
</script>

<style>
   .root {

       writing-mode: sideways-rl;
	   float: left;
   },
   .example-body {
   		padding: 10px;
   		padding-top: 0;
   	}
</style>

<!-- writing-mode:horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr
 -->
